package com.yn.service.zy.model.dto;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.yn.common.model.zy.DeviceRentOrderDO;
import com.yn.common.utils.BeanUtils;
import com.yn.common.utils.MoneyUtils;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Objects;

/**
 * @ClassName: DeviceRentOrderDTO
 * @Description: 设备租赁订单
 * @Author: ym
 * @Date: 2025/5/9 15:57
 **/
@Data
public class DeviceRentOrderDTO {

    /** 主键 */
    @TableId(type = IdType.AUTO)
    private Integer id;
    /** 订单编号 */
    private String deviceOrderNo;
    /** 订单总价格 */
    private BigDecimal deviceOrderPrice;
    /** 订单商品总数 */
    private Integer totalNum;
    /** 押金总金额 */
    private Integer  depositMoney;
    /** 租赁天数 */
    private Integer rentDay;
    /** 订单实际支付金额 */
    private BigDecimal orderPayPrice;
    /** 优惠金额 */
    private BigDecimal preferentialPrice;
    /** 优惠券 */
    private Integer couponId;
    /** 微信支付单号 */
    private String weChatPayNo;
    /** 实际支付金额 */
    private BigDecimal inspectionPayPrice;
    /** 运费金额 */
    private BigDecimal totalPostage;
    /** 退款金额 */
    private BigDecimal orderReturnMoney;
    /** 退款状态 0待审核 1退款中 2退款完成 3退款失败 */
    private Integer orderReturnStatus;
    /** 支付状态 */
    private Integer payStatus;
    /** 支付时间 */
    private LocalDateTime payTime;
    /** 订单状态 0待付款 1待配送 2配送中 3已取消 5已送达 6待评价 7已评价 */
    private Integer orderStatus;
    /** 收件人姓名 */
    private String receiveName;
    /** 收件人手机号 */
    private String receivePhone;
    /** 收件人省 */
    private String receiveProvince;
    /** 收件人市 */
    private String receiveCity;
    /** 收件人区 */
    private String receiveDistrict;
    /** 收件人详细地址 */
    private String receiveAddress;
    /** 订单评价 */
    private String orderEvaluation;
    /** app用户id */
    private Integer appUserId;
    /** 创建时间 */
    private LocalDateTime createTime;
    /** 备注 */
    private String remark;
    /** 快递单号 */
    private String logisticsNumber;
    /** 快递公司 */
    private String logisticsCompany;
    /** 快递公司编码 */
    private String logisticsCode;

    public static DeviceRentOrderDTO transform(DeviceRentOrderDO deviceRentOrderDO) {
        if (Objects.isNull(deviceRentOrderDO)){
            return null;
        }
        DeviceRentOrderDTO deviceRentOrderDTO = BeanUtils.copyProperties(deviceRentOrderDO, DeviceRentOrderDTO.class);
        if (Objects.nonNull(deviceRentOrderDO.getDeviceOrderPrice())){
            deviceRentOrderDTO.setDeviceOrderPrice(MoneyUtils.fen2yuan(deviceRentOrderDO.getDeviceOrderPrice()));
        }
        if (Objects.nonNull(deviceRentOrderDO.getOrderPayPrice())){
            deviceRentOrderDTO.setOrderPayPrice(MoneyUtils.fen2yuan(deviceRentOrderDO.getOrderPayPrice()));
        }
        if (Objects.nonNull(deviceRentOrderDO.getPreferentialPrice())){
            deviceRentOrderDTO.setPreferentialPrice(MoneyUtils.fen2yuan(deviceRentOrderDO.getPreferentialPrice()));
        }
        if (Objects.nonNull(deviceRentOrderDO.getInspectionPayPrice())){
            deviceRentOrderDTO.setInspectionPayPrice(MoneyUtils.fen2yuan(deviceRentOrderDO.getInspectionPayPrice()));
        }
        if (Objects.nonNull(deviceRentOrderDO.getTotalPostage())){
            deviceRentOrderDTO.setTotalPostage(MoneyUtils.fen2yuan(deviceRentOrderDO.getTotalPostage()));
        }
        if (Objects.nonNull(deviceRentOrderDO.getOrderReturnMoney())){
            deviceRentOrderDTO.setOrderReturnMoney(MoneyUtils.fen2yuan(deviceRentOrderDO.getOrderReturnMoney()));
        }

        return deviceRentOrderDTO;
    }
}
